package com.atguigu.tingshu.user.pattern.factory;

import com.atguigu.tingshu.common.execption.GuiguException;
import com.atguigu.tingshu.user.pattern.DeliveryStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ClassName : StrategyFactory
 * Package : com.atguigu.tingshu.user.pattern.factory
 * Description :
 * <p>
 * Author: LHZ
 * Create: 2025/8/1 23:59
 * Version: 1.0
 */
@Slf4j
@Component
@SuppressWarnings("all")
public class DeliveryStrategyFactory {

    @Autowired
    private Map<String,DeliveryStrategy> map;

    public DeliveryStrategy getDeliveryStrategy(String type){
        if(map.containsKey(type)){
            return map.get(type);
        }
        log.error("不包含此类型:{}",type);
        throw new GuiguException(500,"不包含此类型");

    }
}